<template>
	<view>
		<view class="goods-list">
				<view class="goods-item">
					<!-- 商品左侧图片区域 -->
					<view class="goods-item-left">
						<image :src="goods.goods_small_logo || defaultPic" class="goods-pic"></image>
					</view>
					<!-- 商品右侧信息区域 -->
					<view class="goods-item-right">
						<!-- 商品标题 -->
						<view class="goods-name">{{goods.goods_name}}</view>
						<view class="goods-info-box">
							<!-- 商品价格 -->
						<view class="goods-price">${{goods.goods_price | tofixed}}</view>
						</view>
					</view>
				</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"my-goods",
		// 定义props属性,用来接收外界传递当前组件的数据
		// 大概是javasript有先后执行顺序,如果props放在data()后面,则会发生先执行data(),然后执行props这样会造成错误,或者拿不到数据
		props:{
			// 商品信息对象
			goods:{
				type:Object,
				defaul:{}
			}
		},
		data() {
			return {
				// 默认的空图片
				defaultPic:'https://gss0.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/5366d0160924ab1862d30a2539fae6cd7a890bdf.jpg'
			};
		},
		// 过滤器
		filters:{
			tofixed(num){
				return Number(num).toFixed(2)
			}
		}
		
	
	}
</script>

<style lang="scss">
.goods-item{
	display: flex;
	padding: 10px 5px;
	border-bottom: 1px solid #f0f0f0;
	.goods-item-left{
		margin-right: 5px;
		.goods-pic{
			width: 100px;
			height: 100px;
			display: block;
		}
		
	}
	.goods-item-right{
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		.goods-name{
			font-size: 13px;
		}
		.goods-info-box{
			.goods-price{
				color:#C00000;
				font-size: 16px;
			}
		}
	}	
}
</style>